<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<script type="text/javascript" src="static/My97DatePicker/WdatePicker.js"></script>
<style>
	#tableactionTabContent .btn-default{
		margin-bottom: 15px;
	}
	#tableactionTabContent .btn-default.on{
		background: #086176;
    		color: #fff;
    		border-color: #064a59;
	}
	#tableactiondTab .btn-default.on{
		background: #086176;
    		color: #fff;
    		border-color: #064a59;
	}
	#tableactionTabContent{
		position: relative;
		/* height: 40px; */
		padding-top: 20px;
	}
	#tableactionTabContent .tab-pane{
		/* position: absolute; 
		left:52px;
		top:15px;
		float: right;
    	width: 94%;*/
    	width: 90%;
    	vertical-align: top;
	}
	#tableactionTabContent .tab-pane.fade{
		display:none;
	}
	#tableactionTabContent .tab-pane.fade.in{
		display:inline-block;
	}
	.data_status .btn-default.on {
	    background: #086176;
	    color: #fff;
	    border-color: #064a59;
	}
</style>
<div id="page-wrapper">
      <!--BEGIN TITLE & BREADCRUMB PAGE-->
      <div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
          <div class="page-header pull-left">
              <div class="page-title">知识加工</div>
          </div>
          <ol class="breadcrumb page-breadcrumb pull-left">
              <li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
              <li>知识库管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
              <li class="active">知识加工</li>
          </ol>
           
          <div class="clearfix"></div>
      </div>
      <!--END TITLE & BREADCRUMB PAGE-->
      <!--BEGIN CONTENT-->
      <div class="page-content">
       <?if(workflowStatus==1){?><!-- 开启工作流显示 -->
                <div class="col-lg-12" style="margin-bottom: 10px;">           
                   <div class="data_status">数据状态: 
                   <input type="button" data-value="1" data-name="#table-db1-tab" onclick="changeDataType('isnull')" class="btn btn-default dropdown-toggle on" value="草稿库">
                   <input type="button" data-value="1" data-name="#table-db1-tab" onclick="changeDataType('isnotnull')" class="btn btn-default dropdown-toggle" value="正式库">
                   </div>
              </div>
       <?}?>
       <div class="row">
	       <div class="col-lg-12">
		       <div class="note note-danger">
		           <h3 class="box-heading">${headline}</h3>
		           	<input type="hidden" value=${classesEn} name="classesEn" id="classesEn"/>
		           	<input type="hidden" value=${classesId} name="classesId" id="classesId"/>
		           	<input type="hidden" value='1' name="classescount" id="classescount"/>
		           	<input type="hidden" value=${screenContent} name="screenContent" id="screenContent"/>
		           	<input type="hidden" value=${pageNum} name="pageNum" id="pageNum"/>
		           <p>${describe}</p>
		       </div>
		   </div>
	   </div> 
	   <?if(tableactiondTab != '' && tableactiondTab != null){?>
	   <div class="row" style="margin-bottom: 20px;">
	       <div class="col-lg-12">
          	 <!-- 分库分表 start  -->
	          		<div class="col-lg-12">
						<div id="tableactiondTab" >
							数据源：${tableactiondTab}
						</div>
                          <div id="tableactionTabContent">
                              	来源表：${tableactionTabContent}
                          </div>
                      </div>
               <!-- 分库分表 end  -->
		   </div>
	   </div> 
      <?}?>
      <div class="row mbl">
           <div class="col-lg-12" style="float: right;">
               <div class="tb-group-actions pull-right"><span>共有<label id="pageSize"></label>条记录</span>
               			&nbsp;&nbsp;&nbsp;&nbsp;当前记录：
               			<select id="recordCount" name="recordCount">
               				<?for(rec in records){
								if(rec ==pagecount){?>
										<option value="${rec}" selected="selected">${rec}</option>
									<?}else{?>
										<option value="${rec}">${rec}</option>
									<?}
							}?>
               			</select>
               			&nbsp;&nbsp;&nbsp;&nbsp;
               	 <?if(workflowStatus == 0){?><!-- 没有绑定工作流状态下显示 -->
                   <button class="btn btn-sm btn-primary" onclick="add();">新增</button>&nbsp;&nbsp;
                   <button id="displaybtn" class="btn btn-sm btn-primary" onclick="anewAllot();">重新分配数据</button>&nbsp;&nbsp;
                   <button class="btn btn-sm btn-primary" onclick="batchDelete();">批量删除</button>&nbsp;&nbsp;
                 <?}?>
                 <?if(workflowStatus == 1){?><!-- 绑定工作流状态下显示 -->
                   <lable id="Draftsdb"><!-- 草稿库要显示的按钮 -->
                   <button class="btn btn-sm btn-primary" onclick="add();">新增</button>&nbsp;&nbsp;
                   <button id="displaybtn" class="btn btn-sm btn-primary" onclick="anewAllot();">重新分配数据</button>&nbsp;&nbsp;
                   <button class="btn btn-sm btn-primary" onclick="batchDelete();">批量删除</button>&nbsp;&nbsp;
                   </lable>
                   <lable id="Officialdb" style="display: none;"><!--正式库要显示的按钮 -->
                   </lable>
                 <?}?>
                   <button class="btn btn-sm btn-primary" onclick="returnPlant();">返回</button>
               </div>
           </div>
           
           
          <!--2017-02-04 14:46:09 xiaoan 筛选项-start -->
         	${selecttext}
         <!-- 筛选项-end -->
        <!--   
          <div class="col-lg-12" style="margin-top: 10px;">
          	<div class="panel">
          		<div class="panel-heading">筛选：</div>
               <div class="panel-body pan">
               		<div class="form-body pal">
               		<? for(catalogue in seek){ ?>
               		 <div class="form-group" style="float: left;">
               		 <label for="inputName" class="col-md-3 control-label"> ${catalogue.nameZh}:</label>
                      <div class="col-md-9">
                      	<div class="input-icon right">
               			<?if(catalogue.type == 1){ ?>
               			<select id="dictitemName_${catalogue.nameEn}" class="form-control" style="width: 200px;" name="${catalogue.nameEn}">
               			<option selected="selected" value="">请选择</option>
               			<?for(selectList in arrList){
								var selectKey = catalogue.nameEn;
							if(selectKey ==  selectList.key){
							for(seValue in selectList.value){
               			?>
               				<option value="${seValue}">${seValue}</option>
               			<?}}}?>
               			</select>
					<? }if(catalogue.type == 2){ ?>
					<div class="input-group input-group-sm mbs" style="width: 200px;">
						<input id="dictitemName_${catalogue.nameEn}" name="${catalogue.nameEn}" type="text" placeholder="请选择"class="form-control" disabled="true" /> 
							 <span class="input-group-btn">
							<button id="t_${catalogue.nameEn}" onclick="saveEditZTree('${catalogue.typeId}','${catalogue.nameEn}')"
								type="button" data-toggle="dropdown"
								class="btn btn-success dropdown-toggle">选择...</button> 
								</span>
					</div>
					<?}if(catalogue.type == '0'){?>
               			<input type="text" class="form-control" style="width: 150px;" id="dictitemName_${catalogue.nameEn}" name="${catalogue.nameEn}" />
               			<?}?>
               			</div>
               		</div>
               		</div>
                	<?}?>
               	 </div>
               </div>
               <button style="margin-left: 35px;" type="button" data-toggle="dropdown" onclick="demo1()" class="btn btn-success dropdown-toggle">搜索</button>
           </div>
           </div>-->  
           <input type="hidden" id="filtrateContent" name='filtrateContent' value="${filtrateContent}"/>
       </div>
      
      <table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
            <thead>
                <tr>
                    <th width="3%">
                        <input type="checkbox" class="checkall" name="onecheckall" />
                    </th>  
                    <th width="50px"  style="text-align:center">序号</th>
                     <?for( catalogue in catalogueList){?>
                     	<th style=" text-align:center">${catalogue.nameZh}</th>
                    <?}?>
                    <th width="8%" style="text-align:center">可操作</th>
                </tr>
            </thead>
            <tbody id="text">
                 
            </tbody>
        </table>
        <div  id="photos" style="display: none;text-align:center;margin:0 auto;">
		</div>
        <div id="dataNull" class="panel-body"
				style="height: 90px; line-height: 50px;" align="center">
		</div>
        <div id="page2" style="text-align: center; margin-top: 20px;"></div>
    </div>
                     
    <!--END CONTENT-->
    </div>
    
  
<?} ?>
<script type="text/javascript">
var curr;
var buttonType = 1;
var selectOnchangeValue=0;
//页数
function getYe() {  
    return $("#classescount").val();
} 
function getButtonType() {  
    return buttonType;
} 
//添加
function add() { 
	var databaseName = $("#tableactiondTab input.on").attr("data-value");
	var chartName = $("#tableactionTabContent input.on").attr("data-value");
	var classesEn = $("#classesEn").val();
	var classesId = $("#classesId").val();
	location.href="show-edit-data-detail.html?classesId="+classesId+"&classesEn="+classesEn+"&databaseName="+databaseName+"&chartName="+chartName; 
}
//编辑
function update(id,statusType) {
	if(selectOnchangeValue == '0'){
		var filtrateContent = $("#filtrateContent").val();
		var filtrateText = filtrateContent.substring(0,filtrateContent.length-1);
		var strs = new Array(); //定义一数组 
			strs = filtrateText.split(","); //字符分割 
		var screenContent=''; 
		for (i=0;i<strs.length ;i++ ){
			var keys = strs[i];
			if($("#dictitemName_"+strs[i]).val() != null && $("#dictitemName_"+strs[i]).val() != '' && $("#dictitemName_"+strs[i]).val() != undefined){
				if($("#dictitemId_"+strs[i]).val() != '' && $("#dictitemId_"+strs[i]).val() != undefined){
					screenContent+="&"+strs[i]+"="+$("#dictitemName_"+strs[i]).val()+"~"+$("#dictitemId_"+strs[i]).val();
				}else{
					screenContent+="&"+strs[i]+"="+encodeURI($("#dictitemName_"+strs[i]).val());
					
				}
			}else{
				if($("#dictitemName_"+strs[i]+"_startTime").val() != null && $("#dictitemName_"+strs[i]+"_startTime").val() !='' && $("#dictitemName_"+strs[i]+"_startTime").val() != undefined){
					screenContent+="&"+strs[i]+"_startTime="+encodeURI($("#dictitemName_"+strs[i]+"_startTime").val());
				}
				if($("#dictitemName_"+strs[i]+"_endTime").val() != null && $("#dictitemName_"+strs[i]+"_endTime").val() !='' && $("#dictitemName_"+strs[i]+"_endTime").val() != undefined){
					screenContent+="&"+strs[i]+"_endTime="+encodeURI($("#dictitemName_"+strs[i]+"_endTime").val());
				}
			}
		} 
		if($("#dictitemName_selectUser").val() != ''){
			screenContent+="&createUserId="+$("#dictitemName_selectUser").val();
		}
		if($("#dictitemName_startTime").val() != ''){
			screenContent+="&startTime="+$("#dictitemName_startTime").val();
		}
		if($("#dictitemName_endTime").val() != ''){
			screenContent+="&endTime="+$("#dictitemName_endTime").val();
		}
		if($("#dictitemName_status").val() != ''){
			screenContent+="&status="+$("#dictitemName_status").val();
		}
		screenContent+="&curr="+$("#classescount").val();
		var classesEn = $("#classesEn").val();
		var classesId = $("#classesId").val();
		
		var databaseName = $("#tableactiondTab input.on").attr("data-value");
		var chartName = $("#tableactionTabContent input.on").attr("data-value");
		location.href="show-edit-data-detail-update.html?id="+id+"&classesEn="+classesEn+"&classesId="+classesId+screenContent+"&searchType="+buttonType+"&databaseName="+databaseName+"&chartName="+chartName; 
	}else{
		alert("筛选项已改变，请先点击搜索！");
		selectOnchangeValue=0;
	} 
}
//禁用
function forbidden(id,status) {
	var classesEn = $("#classesEn").val();
	var classesId = $("#classesId").val();
	var databaseName = $("#tableactiondTab input.on").attr("data-value");
	var chartName = $("#tableactionTabContent input.on").attr("data-value");
	location.href="knowledge-edit-data-detail-forbidden-method.html?id="+id+"&classesEn="+classesEn+"&classesId="+classesId+"&status="+status+"&databaseName="+databaseName+"&chartName="+chartName; 
}
//删除
function detele(id,statusType) { 
	if (statusType == 2) {
		alert('审核中，请勿操作！');
		return null;
	}
	var classesEn = $("#classesEn").val();
	var classesId = $("#classesId").val();
	var databaseName = $("#tableactiondTab input.on").attr("data-value");
	var chartName = $("#tableactionTabContent input.on").attr("data-value");
	if (confirm("是否确认删除！！")) {
		$.ajax({
			type : "post",
			url : "knowledgeEditDataDetailDeteleMethod.do",
			dataType : "json",
			data :{
					"id":id,
					"classesEn":classesEn,
					"classesId":classesId,
					"databaseName":databaseName,
					"chartName":chartName
			},
			beforeSend : function(XMLHttpRequest) {},
			success : function(res) {
				if(res[0].data == '0'){
					layer.msg('删除成功！');
					demo1($("#classescount").val(),buttonType);
				}else{
					layer.msg('删除失败！');
				}
			},
			error:function(){
				alert("编辑失败");
			}
		});
	}
}

$(document).ready(function () {

	$('.data_status').on('click','.btn-default',function(){
		$(this).addClass('on').siblings().removeClass('on');
	});
 
	$("#recordCount").bind("change",function(){
	 addCookie("recordCount",$("#recordCount").val(),7,"/");  
	 demo1(1,buttonType);
	});
	
	$('#tableactiondTab').on('click','.btn-default',function(){
		var index=$(this).index();
		$(this).addClass('on').siblings().removeClass('on');
		$('#tableactionTabContent').find('.btn-default').removeClass('on');
		$('#tableactionTabContent .tab-pane').eq(index).find('.btn-default').eq(0).addClass('on');
		$('#tableactionTabContent .tab-pane').removeClass('in active');
		$('#tableactionTabContent .tab-pane').eq(index).addClass('in active');
		demo1(1,buttonType);
		
	});
	
	$('#tableactionTabContent').on('click','.btn-default',function(){
		$(this).addClass('on').siblings().removeClass('on');
		 demo1(1,buttonType);
	});
	
});

function addCookie(name,value,days,path){   /**添加设置cookie**/  
    var name = escape(name);  
    var value = escape(value);  
    var expires = new Date();  
    expires.setTime(expires.getTime() + days * 3600000 * 24);  
    //path=/，表示cookie能在整个网站下使用，path=/temp，表示cookie只能在temp目录下使用  
    path = path == "" ? "" : ";path=" + path;  
    //GMT(Greenwich Mean Time)是格林尼治平时，现在的标准时间，协调世界时是UTC  
    //参数days只能是数字型  
    var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString();  
    document.cookie = name + "=" + value + _expires + path;  
}  

$(function(){
	 adminLook();
	  var screenContents = $("#screenContent").val();
		 if(screenContents != '{}' && screenContents !=''&& screenContents !='id="screenContent"'){
		  var url = location.search; //获取url中"?"符后的字串
   			if (url.indexOf("?") != -1) {    //判断是否有参数
	     	     var str = url.substr(1); //从第一个字符开始 因为第0个是?号 获取所有除问号的所有符串
	      		 var strs = str.split("&");   //用等号进行分隔 （因为知道只有一个参数 所以直接用等号进分隔 如果有多个参数 要用&号分隔 再用等号进行分隔）
	     	 	 for (i=0;i<strs.length ;i++ ){
	     	 	 	var str2 = strs[i].split("=");
	     	 	 	if(str2[0] !='curr' && str2[0] !='classesId' && str2[0] !='classesEn'&& str2[0] !='searchType'){
	     	 	 		var splitk = decodeURI(str2[1]).split("~");
	     	 	 		if(splitk.length>1){
	     	 	 			$("#dictitemName_"+str2[0]).val(splitk[0]);
	     	 	 			$("#dictitemId_"+str2[0]).val(splitk[1]);
	     	 	 		}else{
	     	 	 			$("#dictitemName_"+str2[0]).val(decodeURI(str2[1]));
	     	 	 		}
					}
					if(str2[0] =='curr'){
						curr=str2[1];
						$("#classescount").val(str2[1]);
					}
					if(str2[0] =='searchType'){
						buttonType=str2[1];
					}
	     	 	 }
  		 	}
		 }
		 demo1(curr,buttonType);
});
	
	function demo1(curr,searchType){
		buttonType = searchType;
		if(curr == undefined){
			$("#classescount").val("1");
		}
		selectOnchangeValue=0;
		var filtrateContent = $("#filtrateContent").val();
		var filtrateText = filtrateContent.substring(0,filtrateContent.length-1);
		var strs = new Array(); //定义一数组 
			strs = filtrateText.split(","); //字符分割 
		var screenContent = {}; 
		for (i=0;i<strs.length ;i++ ){
			var keys = strs[i];
			if($("#dictitemId_"+strs[i]).val() != '' && $("#dictitemId_"+strs[i]).val() != undefined){
				screenContent[keys] = $("#dictitemId_"+strs[i]).val();
			}else{
				if($("#dictitemName_"+strs[i]).val() != '' && $("#dictitemName_"+strs[i]).val() != undefined){
					screenContent[keys] = $("#dictitemName_"+strs[i]).val();
				}else{
					if($("#dictitemName_"+strs[i]+"_startTime").val() != null && $("#dictitemName_"+strs[i]+"_startTime").val() !='' && $("#dictitemName_"+strs[i]+"_startTime").val() != undefined){
						if($("#dictitemName_"+strs[i]+"_endTime").val() == null || $("#dictitemName_"+strs[i]+"_endTime").val() == '' || $("#dictitemName_"+strs[i]+"_endTime").val() == undefined){
							layer.msg('请选择结束时间，结束时间必须大于开始时间1天！');
						}else{
							screenContent[keys] = $("#dictitemName_"+strs[i]+"_startTime").val()+"#"+$("#dictitemName_"+strs[i]+"_endTime").val();
						}
					}
					if($("#dictitemName_"+strs[i]+"_endTime").val() != null && $("#dictitemName_"+strs[i]+"_endTime").val() !='' && $("#dictitemName_"+strs[i]+"_endTime").val() != undefined){
						if($("#dictitemName_"+strs[i]+"_startTime").val() == null || $("#dictitemName_"+strs[i]+"_startTime").val() == '' || $("#dictitemName_"+strs[i]+"_startTime").val() == undefined){
							layer.msg('请选择开始时间，开始时间必须小于开始时间1天！');
						}else{
							screenContent[keys] = $("#dictitemName_"+strs[i]+"_startTime").val()+"#"+$("#dictitemName_"+strs[i]+"_endTime").val();
						}
					}
				}
				
			}
		} 
		screenContent['create_user_id'] = $("#dictitemName_selectUser").val();
		screenContent['status'] = $("#dictitemName_status").val();
		if($("#dictitemName_startTime").val() != null && $("#dictitemName_startTime").val() !='' &&$("#dictitemName_startTime").val() != undefined){
			if($("#dictitemName_endTime").val() == null || $("#dictitemName_endTime").val() == ''){
				layer.msg('请选择结束时间，结束时间必须大于开始时间1天！');
			}else{
				screenContent['create_user_time'] = $("#dictitemName_startTime").val()+"#"+$("#dictitemName_endTime").val();
			}
		}
		if($("#dictitemName_endTime").val() != null && $("#dictitemName_endTime").val() !='' &&$("#dictitemName_endTime").val() != undefined){
			if($("#dictitemName_startTime").val() == null || $("#dictitemName_startTime").val() == ''){
				layer.msg('请选择开始时间，开始时间必须小于开始时间1天！');
			}else{
				screenContent['create_user_time'] = $("#dictitemName_startTime").val()+"#"+$("#dictitemName_endTime").val();
			}
		}
		screenContent['relevance_time'] = $("#dictitemName_relevanceStartTime").val()+"#"+$("#dictitemName_relevanceEndtTime").val();
		var databaseName = $("#tableactiondTab input.on").attr("data-value");
		var chartName = $("#tableactionTabContent input.on").attr("data-value");
		console.log(databaseName);
		$.ajax({
			type : "post",
			url : "knowledge-edit-data-list-text.html",
			dataType : "json",
			data:{
				"page": curr || 1 ,
       			"classesEn":$("#classesEn").val(),
       			"classesId":$("#classesId").val(),
				"screenContent":JSON.stringify(screenContent),
				"searchType":searchType,
				"databaseName":databaseName,
				"chartName":chartName,
			},
			
    		beforeSend : function(XMLHttpRequest) {},
			success:function(res){
			var domeen =$("#classesEn").val();
			//alert(JSON.stringify(res));
      		  var str = "";   
      		  var ye;
      		  var overallCount;
      		 $("#text").html("");
      		  var formalOrDraft=res[res.length-1].formalOrDraft;
       			for(var i=0;i<res.length;i++){
       				if(res[i].id != null){	
		           		 str+="<tr ondblclick=\"update('"+res[i].id+"','"+res[i].statusType+"')\">";
		           		 if(res[i].statusType == '2'){
		           			str+="<td></td>"; 
		           		 }else{
		           			str+="<td><input type='checkbox' name='checkall' value='"+res[i].id+"'/></td>"; 
		           		 }
		                str+="<td  style=''>"+(i+1)+"</td>" 
		           		+"<?for(enList in catalogueList){?>"
			           		+"<?if(enList.dataType=='text_no_word' || enList.dataType=='text_word' || enList.dataType=='number'){?>"
			           			+"<td style='text-align:left'>";
			           			if(res[i].${enList.nameEn}!=null){
			           				str+=res[i].${enList.nameEn};
			           			}
			           			/* +"<span><input class='inputClass' id='${enList.nameEn}_"+i+"' type='text'value="+res[i].${enList.nameEn}+" /></span>"
			           			+"<button type='button' onclick='partUpdate(\"${enList.nameEn}_"+i+"\",\"${enList.nameEn}_"+i+1+"\","+res[i].id+",\"${enList.nameEn}\")'  class='btn btn-default btn-xs'><i class='fa fa-edit'></i></button></td>"  */
			           		str+="<?}else{?>"
			           			+"<td style='text-align:center'>";
			           			if(res[i].${enList.nameEn}!=null){
			           				str+=res[i].${enList.nameEn};
			           			}
			           		str+="</td><?}?>"
		           		+"<?}?>";
		           		/* if(res[i].status == 0){
		           			str+="<td  style='text-align:center'><span class='label label-sm label-success'>未发布</span></td>"; 
		           		}else{
		           			str+="<td  style='text-align:center'><span class='label label-sm label-success'>已发布</span></td>"; 
		           		} */
		           		str+="<td  style='text-align:center'>";
		           		/* if(res[i].status == 0){
		                	str+="<button type='button' class='btn btn-default btn-xs' onclick=\"forbidden('"+ res[i].id+"','"+1+"')\">禁用</button>";
		                }else{
		                	str+="<button type='button' class='btn btn-default btn-xs' onclick=\"forbidden('"+ res[i].id+"','"+0+ "')\">启用</button>";
		                } */
		              if(null!=formalOrDraft){// formalOrDraft 为null 的话则说明该知识库没有绑定工作流  则显示默认的操作按钮 
		                if("isnull"==formalOrDraft){//草稿库
		                  str+="<button type='button' style='margin-right: 5px;' class='btn btn-default btn-xs' onclick=\"update('"+ res[i].id+ "','"+res[i].statusType+"')\">编辑</button>";
		                if(domeen == 'ke_hu_zi_liao'){
		                	if(res[i].username == 'admin'){
		                		str+="<button type='button' class='btn btn-default btn-xs' onclick=\"detele('"+ res[i].id+ "','"+res[i].statusType+"')\">删除</button><br/>";
		                	}
		                }else{
		                	str+="<button type='button' class='btn btn-default btn-xs' onclick=\"detele('"+ res[i].id+ "','"+res[i].statusType+"')\">删除</button><br/>";
		                }
		                 str+="<button type='button' style='margin-top: 5px;' class='btn btn-default btn-xs' onclick=\"versions('"+ res[i].id+ "')\">版本管理</button>";
		                 str+="<button type='button' style='margin-top: 5px;' class='btn btn-default btn-xs' onclick=\"toSubmitData('"+ res[i].id+ "')\">提交</button>";
		                 
		                 }
		                 if("isnotnull"==formalOrDraft){//正式库 
		                   str+="<button type='button' style='margin-top: 5px;' class='btn btn-default btn-xs' onclick=\"oneToExamine('"+ res[i].id+ "')\">撤销</button>"; 
		                   str+="<button type='button' style='margin-top: 5px;' class='btn btn-default btn-xs' onclick=\"xiajiaMethod('"+ res[i].id+ "')\">下架</button>"; 
		                   str+="<button type='button' style='margin-top: 5px;' class='btn btn-default btn-xs' onclick=\"queryDetails('"+ res[i].id+ "')\">详情</button>"; 
		                 }
		               }else{// formalOrDraft 为null 的话则说明该知识库没有绑定工作流  则显示默认的操作按钮
		                 str+="<button type='button' style='margin-right: 5px;' class='btn btn-default btn-xs' onclick=\"update('"+ res[i].id+ "','"+res[i].statusType+"')\">编辑</button>";
		                if(domeen == 'ke_hu_zi_liao'){
		                	if(res[i].username == 'admin'){
		                		str+="<button type='button' class='btn btn-default btn-xs' onclick=\"detele('"+ res[i].id+ "','"+res[i].statusType+"')\">删除</button><br/>";
		                	}
		                }else{
		                	str+="<button type='button' class='btn btn-default btn-xs' onclick=\"detele('"+ res[i].id+ "','"+res[i].statusType+"')\">删除</button><br/>";
		                }
		               }
		                /*  str+="<button type='button' class='btn btn-default btn-xs' onclick=\"publish('"+ res[i].id+ "')\">发布</button>"; */ 
		            	str+="</td>"
		        			+"</tr>"
        			}
        			
        		 if(res[i].id == null){
		      		 document.getElementById('pageSize').innerHTML=0;
		      		 $("#dataNull").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
	      		 }else{
	      		 	$("#dataNull").hide();
	      		 }
        		if(res[i].pageCount !=null){
        			ye=res[i].pageCount;
        		}
        		if(res[i].overallCount !=null){
        			overallCount=res[i].overallCount;
        		}
       		 }
       		 if(ye == '1'){
       		 	$("#classescount").val("1");
       		 }
       		 
				$("#text").append(str);
				$(".inputClass").hide();
				
			document.getElementById('pageSize').innerHTML=overallCount;
			laypage({
				cont : document.getElementById("page2"), //容器。值支持id名、原生dom对象，jquery对象,
				pages : ye, //总页数
				skip : true, //是否开启跳页
				curr : curr || 1,
				last: false, 
				first: false,
				skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
				groups : 6,//连续显示分页数
				jump : function(obj, first) { //触发分页后的回调
					if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
						demo1(obj.curr,searchType);
		                 curr=obj.curr;
		                 $("#classescount").val(obj.curr);
					}
				}
			});
		
		
		
		
		
    } 
});
	
}
	
	//返回工厂
	function returnPlant(){
		location.href="show-edit-data-class.html";
	}
	
	//局部编辑
	function partUpdate(inputid,spanid,id,key){
	$("#"+inputid).show().focus();
	$("#"+spanid).hide();
		$("#"+inputid).blur(function(){
			var text = $("#"+inputid).val();
			var classesEn = $("#classesEn").val();
				$.ajax({
					type : "post",
					url : "knowledge-edit-data-partUpdate-ajax.html",
					dataType : "json",
					data:{
						"text": text ,
       					"id":id,
       					"key":key,
       					"classesEn":classesEn
					},
    				beforeSend : function(XMLHttpRequest) {},
					success:function(res){
						//alert(res.result);
						$("#"+spanid).html("");
						$("#"+spanid).append(res.result);
					},
					error:function(){
						alert("编辑失败");
					}
		
			})
			$("#"+inputid).hide();
			$("#"+spanid).show();
		})
	}
	
	//图片放大
	function querypho(pictures){
	 $("#photos").html("");
	 	var pho="";
	 	pho+="<img src=\""+pictures+"\" width='600px' height='500px'/>"
	 	$("#photos").html(pho);
	var index=layer.open({
		  type: 1,
		  title: false,
		  closeBtn: 1,
		  area: ['600px','500px'],
		  skin: 'layui-layer-nobg', //没有背景色
		  shadeClose: true,
		  content: $('#photos')
		});
		layer.iframeAuto(index);
	
	}	
	
	//批量删除
	function batchDelete(){
		var value=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});
		var databaseName = $("#tableactiondTab input.on").attr("data-value");
		var chartName = $("#tableactionTabContent input.on").attr("data-value");
		if(value != ""){
			if (confirm("是否确认删除全部！！")){
				$.ajax({
					type : "post",
					data : {
						"ids" : value,
						"databaseName" : databaseName,
						"chartName" : chartName,
						"classesEn" : $("#classesEn").val(),
						"classesId" : $("#classesId").val(),
					},
					url : "deleteknowledgeAll.do",
					dataType : "json",
					traditional : true,
					beforeSend : function(XMLHttpRequest) {},
					success : function(data){
						if(data=='0'){
							layer.msg('删除成功！');
							demo1($("#classescount").val(),buttonType); 
						}else{
							layer.msg('删除失败！');
							$("input[name=checkall]").each(function(){
							   $(this).removeAttr("checked");
							});
						}
						
					},
				});
			}
		}else{
			layer.msg('请勾选要删除的内容！');
		}
	}
	var value;
	function getvalue() {  
            return value;
    } 
	function getclassesEn() {  
            return classesEn = $("#classesEn").val();
    } 
    //判断是否为管理员登录
    function adminLook(btnId,data){
    	var en =$("#classesEn").val();
    	$.ajax({
				type : "post",
				url : "superAdmin.do",
				data : {},
				dataType : "json",
				beforeSend : function(XMLHttpRequest) {},
				success : function(data) {
				if(data =='1'){
					document.getElementById('displaybtn').style.display="";
					//demo1();
					
				}else{
					document.getElementById('displaybtn').style.display="none"; 
				}
				},
			});
    } 
    var databaseNamevalue;
	function getDatabaseNamevalue() {  
         return databaseNamevalue;
    } 
	var chartNamevalue;
	function getChartNamevalue() {  
        return chartNamevalue;
    } 
	//重新分配
	function anewAllot(){
		value=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});
		databaseNamevalue = $("#tableactiondTab input.on").attr("data-value");
		chartNamevalue = $("#tableactionTabContent input.on").attr("data-value");
		if(value != ""){
				layer.open({
				type : 2,
				area : [ '800px', '500px' ],
			    scrollbar: false,
			    shadeClose: true,
				fix : false, //不固定
				title : '用户管理',
				//maxmin : true,  
				skin: 'layui-layer-rim', //加上边框
	    	    btn: ['保存 ','关闭'],
				content : ["knowledge-edit-data-users.html",'no'],
				yes: function(index,layer){
		                var iframeWin = parent.window[layer.find('iframe')[0]['name']];
		                 iframeWin.save();
		         },
				cancel : function(index) {
				}
			
		});
		}else{
			layer.msg('请勾选要重新分配的内容！');
		}
	}
	/* function selectAll(){
		 $("#selectAllName").html("");
		 var stc='';
       		for(var i=0;i<res.length;i++){
       			if(){
       			stc+=''
       				}
	} */
	var dictId ;
	var oncliDataId ;
	function getdictIdZTree(){
		return dictId
	}
	function getoncliDataId(){
		return oncliDataId;
	}
	function saveEditZTree(id,oncliId) {
		dictId=id;
		oncliDataId= oncliId;
		layer.open({
					type : 2,
					area : [ '700px', '530px' ],
					fix : false, //不固定
					maxmin : true,
					scrollbar : false,
					shadeClose : true,
					title : '字典项管理',
					btn : [ '保存 ', '关闭' ],
					skin : 'layui-layer-rim', //加上边框
					content : ["knowledge-edit-data-ztree.html",'no'],
					yes : function(index, layer) {
						//alert(index);
						 var iframeWin = parent.window[layer.find('iframe')[0]['name']];
						//alert(iframeWin);
						iframeWin.queren();
					},
					cancel : function(index) {
					}
				});
			}
	//清空
	function deleteselect(){
	
		var filtrateContent = $("#filtrateContent").val();
		var filtrateText = filtrateContent.substring(0,filtrateContent.length-1);
		var strs = new Array(); //定义一数组 
			strs = filtrateText.split(","); //字符分割 
		var screenContent = {}; 
		for (i=0;i<strs.length ;i++ ){
			var keys = strs[i];
			$("#dictitemName_"+strs[i]).val(""); 
			$("#dictitemName_"+strs[i]+"_startTime").val(""); 
			$("#dictitemName_"+strs[i]+"_endTime").val(""); 
			$("#dictitemId_"+strs[i]).val(""); 
		} 
		$("#dictitemName_selectUser").val("");
		$("#dictitemName_startTime").val("");
		$("#dictitemName_endTime").val("");
		$("#dictitemName_status").val("");
	}
	//批量操作客户级别
	function operation(){
	var keHuJiBie=$("#dictitemName_ke_hu_ji_bie").val();
	var value=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});
		if(value != ''){
			$.ajax({
					type : "post",
					url : "bassOperation.do",
					dataType : "json",
					data:{
       					"id":value,
       					"keHuJiBie":keHuJiBie,
       					"classesEn":$("#classesEn").val()
					},
					traditional : true,
    				beforeSend : function(XMLHttpRequest) {},
					success:function(data){
						if(data == 'yes'){
							 demo1($("#classescount").val(),buttonType);
							 layer.msg('修改成功！');
						}else{
							layer.msg('修改失败！');
						}
					},
					error:function(){
						alert("编辑失败");
					}
		
			})
			}else{
				layer.msg('请勾选内容！');
			}
	}
	
function issueButton1(){
	var databaseName = $("#tableactiondTab input.on").attr("data-value");
	var chartName = $("#tableactionTabContent input.on").attr("data-value");
	if (confirm("是否确认发布(不含全文)！建议总数量小于10万时使用.")){
		layer.msg('数据正在发布中，请稍候几分钟后在检索平台刷新页面获取最新数据。');
		$.ajax({
				type : "post",
				url : "knowledgeEditDataIssue.do",
				dataType : "json",
				data:{
      				"classesEn":$("#classesEn").val(),
      				"databaseName":databaseName,
      				"chartName":chartName,
				},
   				beforeSend : function(XMLHttpRequest) {},
				success:function(res){
					if(res == 'yes'){
							 demo1($("#classescount").val(),buttonType);
							 layer.msg('发布成功！');
						}else{
							layer.msg('发布失败！');
						}
				},
				error:function(){
					//alert("发布失败");
				}
	
		});
	}
}
function issueButton2(){
	var databaseName = $("#tableactiondTab input.on").attr("data-value");
	var chartName = $("#tableactionTabContent input.on").attr("data-value");
	if (confirm("是否确认发布(含全文)！建议总数量小于10万时使用.")){
		layer.msg('数据正在发布中，请稍候几分钟后在检索平台刷新页面获取最新数据。');
		$.ajax({
				type : "post",
				url : "dataSubmitAllWithAttachment.do",
				dataType : "json",
				data:{
      				"classesEn":$("#classesEn").val(),
      				"databaseName":databaseName,
      				"chartName":chartName,
				},
   				beforeSend : function(XMLHttpRequest) {},
				success:function(res){
					if(res == 'yes'){
							 demo1($("#classescount").val(),buttonType);
							 layer.msg('发布成功！');
						}else{
							layer.msg('发布失败！');
						}
				},
				error:function(){
					//alert("发布失败");
				}
	
		});
	}
}
function publish(publishId){
	if (confirm("是否确认发布！！")){
		var databaseName = $("#tableactiondTab input.on").attr("data-value");
		var chartName = $("#tableactionTabContent input.on").attr("data-value");
		$.ajax({
				type : "post",
				url : "knowledgeEditDataPublish.do",
				dataType : "json",
				data:{
      				"classesEn":$("#classesEn").val(),
      				"id":publishId,
      				"databaseName":databaseName,
      				"chartName":chartName,
				},
   				beforeSend : function(XMLHttpRequest) {},
				success:function(res){
					if(res == 'yes'){
							 demo1($("#classescount").val(),buttonType);
							 layer.msg('发布成功！');
						}else{
							layer.msg('发布失败！');
						}
				},
				error:function(){
					alert("发布失败");
				}
	
		});
	}
}
/* 防止选择后未点搜索 start */
$(document).ready(function () { 
  $(".form-control").bind("change",function(){ 
  	selectOnchangeValue=1;
  }); 
});
function selectOnchange(){
	selectOnchangeValue=1;
}
/* end */
 
 //审核
function auditWord(auditStatus){
	var value=[];
	$("input[name='checkall']:checked").each(function(){
		value.push($(this).val());
	});
	var databaseName = $("#tableactiondTab input.on").attr("data-value");
	var chartName = $("#tableactionTabContent input.on").attr("data-value");
	if(value != ''){
		$.ajax({
				type : "post",
				url : "auditStatus.do",
				dataType : "json",
				data:{
   					"id":value,
   					"status":auditStatus,
   					"classesEn":$("#classesEn").val(),
   					"databaseName":databaseName,
      				"chartName":chartName,
				},
				traditional : true,
				beforeSend : function(XMLHttpRequest) {},
				success:function(data){
					if(data == 'yes'){
						 demo1($("#classescount").val(),buttonType);
						 layer.msg('操作成功！');
					}else{
						layer.msg('操作失败！');
					}
				},
				error:function(){
					alert("编辑失败");
				}
	
		})
		}else{
			layer.msg('请勾选内容！');
		}
}
//版本管理
var knowledgeVersionsId;
function getKnowledgeVersionsId(){
	return knowledgeVersionsId;
}
function versions(versionsId){
	knowledgeVersionsId = versionsId;
	layer.open({
		type : 2,
		area : [ '800px', '610px' ],
	    scrollbar: false,
	    shadeClose: true,
		fix : true, //不固定
		title : '所有版本',
		//maxmin : true,  
		skin: 'layui-layer-rim', //加上边框
	    btn: [ '关闭'],
		content : ["knowledge-edit-data-versions.html",'no'],
	});
	
}

  //切换正式库和草稿库
  function changeDataType(type){
   $("#dictitemName_status").val(type);
   
   if("isnull"==type)//是草稿库  则正式库隐藏
   {
    $("#Officialdb").css("display","none");
    $("#Draftsdb").css("display","");
  }
  
  if("isnotnull"==type)//是正式库  则草稿库隐藏
   {
    $("#Draftsdb").css("display","none");
    $("#Officialdb").css("display","");
  }
  
    demo1(1,0);
    
 } revocationProcess
  //正式库 单个撤销撤销   
 function oneToExamine(id){
        value=[];
		value.push(id);
		databaseNamevalue = $("#tableactiondTab input.on").attr("data-value");
		chartNamevalue = $("#tableactionTabContent input.on").attr("data-value");
		if(value != ""){
				layer.open({
				type : 2,
				area : [ '800px', '500px' ],
			    scrollbar: false,
			    shadeClose: true,
				fix : false, //不固定
				title : '撤销',
				//maxmin : true,  
				skin: 'layui-layer-rim', //加上边框
	    	    btn: ['保存 ','关闭'],
				content : ["knowledge_edit_workflow_users.html",'no'],
				yes: function(index,layer){
		                var iframeWin = parent.window[layer.find('iframe')[0]['name']];
		                 iframeWin.save();
		         },
				cancel : function(index) {
				}
			
		});
		}else{
			layer.msg('请勾选要撤销的内容！');
	}
 }
  //正式库   批量撤销   
 function batchToExamine(){
        value=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});
		databaseNamevalue = $("#tableactiondTab input.on").attr("data-value");
		chartNamevalue = $("#tableactionTabContent input.on").attr("data-value");
		if(value != ""){
				layer.open({
				type : 2,
				area : [ '800px', '500px' ],
			    scrollbar: false,
			    shadeClose: true,
				fix : false, //不固定
				title : '批量撤销',
				//maxmin : true,  
				skin: 'layui-layer-rim', //加上边框
	    	    btn: ['保存 ','关闭'],
				content : ["knowledge_edit_workflow_users.html",'no'],
				yes: function(index,layer){
		                var iframeWin = parent.window[layer.find('iframe')[0]['name']];
		                 iframeWin.save();
		         },
				cancel : function(index) {
				}
			
		});
		}else{
			layer.msg('请勾选要撤销的内容！');
	}
 }
     //详情
	function queryDetails(detailsId,targetShardingDataSourceId,targetTableName){
     	var relevances='${classesId}';
		choiceId=detailsId;
		choicerRelevanceId=$("#resid").val();
		layer.open({
			type: 2,
			title: '',
			shadeClose: true,
			btn : [ '关闭' ],
			area: ['800px', '600px'],
			content: "querychoicerrelevance?classesId="+relevances+"&id="+detailsId+"&dataSourceId="+targetShardingDataSourceId+"&targetTableName="+targetTableName,//iframe的url
			yes : function(index, layer) {
				var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				iframeWin.save();
			},
			cancel : function(index) {
			}
		
			});
		}
	 function xiajiaMethod(id){
	   var value=[];
	   value.push(id);
	   var classesEn= $("#classesEn").val()
	   var databaseName = $("#tableactiondTab input.on").attr("data-value");
	   var chartName = $("#tableactionTabContent input.on").attr("data-value");
		$.ajax({
				type : "post",
				url : "xiajiaMethod.do",
				dataType : "json",
				data:{
   					"id":value,
   					"classesEn":classesEn
				},
				traditional : true,
				beforeSend : function(XMLHttpRequest) {},
				success:function(data){
					alert("下架成功!");
					demo1(1,0);	
				},
				error:function(){
					alert("下架失败!");
				}
	
		});
	 
	 }
   //知识加工提交数据
   function toSubmitData(id){
    var value=[];
	value.push(id);
	var classesEn= $("#classesEn").val()
	var databaseName = $("#tableactiondTab input.on").attr("data-value");
	var chartName = $("#tableactionTabContent input.on").attr("data-value");
		$.ajax({
				type : "post",
				url : "toSubmitData.do",
				dataType : "json",
				data:{
   					"id":value,
   					"classesEn":classesEn
				},
				traditional : true,
				beforeSend : function(XMLHttpRequest) {},
				success:function(data){
					alert("提交成功!");
					demo1(1,0);	
				},
				error:function(){
					alert("提交失败!");
				}
	
		});
		
   }
</script>